<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<f:view>
	<h:form id='form'>
		<h:head>
			<f:loadBundle basename="messages" var="msgs" />
			<title><h:outputText value="#{msgs.title}" /></title>

			<style type="text/css" title="currentStyle">
				@import "${facesContext.externalContext.requestContextPath}/resources/css/datatable_page.css";
				@import "${facesContext.externalContext.requestContextPath}/resources/css/datatable_table.css";
				@import "${facesContext.externalContext.requestContextPath}/views/css/theme.css";
				@import "${facesContext.externalContext.requestContextPath}/resources/css/header.css";
				@import "${facesContext.externalContext.requestContextPath}/resources/css/themes/base/jquery.ui.all.css";
			</style>

			<script type="text/javascript" src="${facesContext.externalContext.requestContextPath}/resources/script/jquery.js"></script>
			<script type="text/javascript"
				src="${facesContext.externalContext.requestContextPath}/resources/script/jquery.dataTables.js"></script>


			<script src="${facesContext.externalContext.requestContextPath}/resources/script/jquery.bgiframe-2.1.2.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.core.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.widget.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.mouse.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.button.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.draggable.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.position.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.resizable.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.ui.dialog.js"></script>
			<script src="${facesContext.externalContext.requestContextPath}/resources/script/ui/jquery.effects.core.js"></script>
			<script type="text/javascript"
				src="${facesContext.externalContext.requestContextPath}/views/management/scripts/transaction_references.js"></script>
			<script type="text/javascript"
				src="${facesContext.externalContext.requestContextPath}/views/scripts/global.js"></script>
			<script type="text/javascript" charset="utf-8">
				$(document)
					.ready(
						function() {
							$('#transaction_references_table')
								.dataTable();

							$("#dialog-form")
								.dialog(
								{
									autoOpen : false,
									height : 500,
									width : 400,
									modal : true,
									buttons : {
										"Submit" : function() {
											$("[id='form:edit_prefix']").val(
															$("[id='form:edit_transaction_reference_prefix']").val());
											$("[id='form:edit_description']").val(
															$("[id='form:edit_transaction_reference_description']").val());
											$("[id='form:edit_start']").val(
															$("[id='form:edit_transaction_reference_last']").val());
											$("[id='form:edit_last']").val(
															$("[id='form:edit_transaction_reference_last']").val());
											$("[id='form:edit_max']").val(
															$("[id='form:edit_transaction_reference_max']").val());
											$('[id="form:edit_link"]').click();
										},
										/*
										"Delete" : function() {
											$('[id="form:delete_link"]').click();
											
										},
										*/
										Cancel : function() {
											$(this).dialog("close");
										}

									},
									close : function() {
								}
							});

							checkCurrentUserGroup(#{userService.currentUserGroupAdmin});
						});

				
			</script>




		</h:head>
		<body>



			<ui:include src="../header/header.xhtml" />
			<br />
			<br />
			<br />
			<div id="content">
				<h3><h:outputText value="#{msg.transaction_reference_title}" /></h3>
				<br />
				<div>
					<h:commandButton value="#{msg.add_transaction_reference}"
						action="#{transactionReferencesBean.addTransactionReferenceAction}">
					</h:commandButton>
				</div>
				<p></p>

				<div>
					<table class="display" id="transaction_references_table">
						<thead>
							<tr>
								<th><h:outputText value="#{msg.transaction_reference_name}" /></th>
								<th><h:outputText
										value="#{msg.transaction_reference_prefix}" /></th>
								<th><h:outputText
										value="#{msg.transaction_reference_start}" /></th>
								<th><h:outputText value="#{msg.transaction_reference_last}" /></th>
								<th><h:outputText value="#{msg.transaction_reference_max}" /></th>
								<th><h:outputText value="#{msg.transaction_reference_group}" /></th>
								<th><h:outputText value="#{msg.edit}" /></th>
								<th class="admin_field"><h:outputText value="#{msg.delete}" /></th>
							</tr>
						</thead>
						<tbody>
							<ui:repeat var="transactionReference"
								value="#{transactionReferencesBean.transactionReferences}">
								<tr>
									<td><h:outputText value="#{transactionReference.name}" /></td>
									<td><h:outputText value="#{transactionReference.prefix}" /></td>
									<td><h:outputText value="#{transactionReference.start}" /></td>
									<td><h:outputText value="#{transactionReference.last}" /></td>
									<td><h:outputText value="#{transactionReference.max}" /></td>
									<td><h:outputText value="#{transactionReference.groupCode}" /></td>
									<td><a id="#{transactionReference.name}_edit_link"
										href="#"
										onclick="editLinkOnclick('#{transactionReference.name}')">#{msg.edit}</a></td>
									<td class="admin_field"><h:commandLink value="#{msg.delete}"
											id="#{transactionReference.name}_delete_link"
											action="#{transactionReferencesBean.deleteTransactionReferenceAction(transactionReference.name)}" 
											onclick="return deleteLinkOnclick('#{transactionReference.name}')"/></td>
								</tr>
							</ui:repeat>

						</tbody>

						<tfoot>
							<tr>
								<th><h:outputText value="#{msg.transaction_reference_name}" /></th>
								<th><h:outputText
										value="#{msg.transaction_reference_prefix}" /></th>
								<th><h:outputText
										value="#{msg.transaction_reference_start}" /></th>
								<th><h:outputText value="#{msg.transaction_reference_last}" /></th>
								<th><h:outputText value="#{msg.transaction_reference_max}" /></th>
								<th><h:outputText value="#{msg.transaction_reference_group}" /></th>
								<th><h:outputText value="#{msg.edit}" /></th>
								<th class="admin_field"><h:outputText value="#{msg.delete}" /></th>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
			<div id="dialog-form" title="Edit Transaction Reference">
				<h1></h1>
				<table>
					<tr>
						<td><h:outputLabel value="#{msg.transaction_reference_name}">
							</h:outputLabel></td>
						<td><h:inputText id="edit_transaction_reference_name"
								disabled="true"
								value="#{transactionReferencesBean.editTransactionReferenceName}"></h:inputText></td>
					</tr>
					<tr>
						<td><h:outputLabel
								value="#{msg.transaction_reference_prefix}">
							</h:outputLabel></td>
						<td><h:inputText id="edit_transaction_reference_prefix"
								value="#{transactionReferencesBean.editTransactionReferencePrefix}"></h:inputText>
						</td>
					</tr>

					<tr>
						<td><h:outputLabel
								value="#{msg.transaction_reference_description}">
							</h:outputLabel></td>
						<td><h:inputTextarea
								id="edit_transaction_reference_description"
								value="#{transactionReferencesBean.editTransactionReferenceDescription}">
							</h:inputTextarea></td>
					</tr>
					<tr>
						<td><h:outputLabel value="#{msg.transaction_reference_start}">
							</h:outputLabel></td>
						<td><h:inputText id="edit_transaction_reference_start"
								value="#{transactionReferencesBean.editTransactionReferenceStart}">
							</h:inputText></td>
					</tr>
					<tr>
						<td><h:outputLabel value="#{msg.transaction_reference_last}">
							</h:outputLabel></td>
						<td><h:inputText id="edit_transaction_reference_last"
								value="#{transactionReferencesBean.editTransactionReferenceLast}">
							</h:inputText></td>
					</tr>
					<tr>
						<td><h:outputLabel value="#{msg.transaction_reference_max}">
							</h:outputLabel></td>
						<td><h:inputText id="edit_transaction_reference_max"
								value="#{transactionReferencesBean.editTransactionReferenceMax}">
							</h:inputText></td>
					</tr>


				</table>
			</div>



			<div id="hidden_div" class="hidden_input" >
				<p>

					<h:commandButton id="load_btn" value="Load">
						<f:ajax
							render="edit_transaction_reference_prefix edit_transaction_reference_description edit_transaction_reference_start edit_transaction_reference_last edit_transaction_reference_max"
							listener="#{transactionReferencesBean.loadTransactionReferenceAction}" />
					</h:commandButton>

					<h:inputText id="edit_name"
						value="#{transactionReferencesBean.editTransactionReferenceName}">
					</h:inputText>
					<h:inputText id="edit_description"
						value="#{transactionReferencesBean.editTransactionReferenceDescription}">
					</h:inputText>
					<h:inputText id="edit_prefix"
						value="#{transactionReferencesBean.editTransactionReferencePrefix}">
					</h:inputText>
					<h:inputText id="edit_start"
						value="#{transactionReferencesBean.editTransactionReferenceStart}">
					</h:inputText>
					<h:inputText id="edit_last"
						value="#{transactionReferencesBean.editTransactionReferenceLast}">
					</h:inputText>
					<h:inputText id="edit_max"
						value="#{transactionReferencesBean.editTransactionReferenceMax}">
					</h:inputText>


					<h:commandLink value="#{msg.submit}" id="edit_link"
						action="#{transactionReferencesBean.updateTransactionReferenceAction}">
					</h:commandLink>
					<h:commandLink id="delete_link" value="#{msg.delete}"
						action="#{transactionReferencesBean.deleteTransactionReferenceAction('')}" onclick="return deleteLinkOnclick('#{transactionReferencesBean.editTransactionReferenceName}')">
					</h:commandLink>



				</p>
			</div>
			<ui:include src="../footer/footer.xhtml" />
		</body>


	</h:form>
</f:view>
</html>
